
export const setDb = (k, value) => {
  localStorage.setItem(k, value)
}
export const setSessionDb = (k, value) => {
  sessionStorage.setItem(k, value)
}
export const getDb = k => {
  return localStorage.getItem(k)
}
export const getSessionDb = k => {
  return sessionStorage.getItem(k)
}
export const removeDb = k => {
  return localStorage.removeItem(k)
}
export const removeSessionDb = k => {
  return sessionStorage.removeItem(k)
}
// 深拷贝
export const deepCopy = obj => {
  return JSON.parse(JSON.stringify(obj))
}
// 手机号的正则
export const regPhone = /^1(3|4|5|6|7|8|9)\d{9}$/
// 银行卡的正则
export const regBankCard = /^([1-9]{1})(\d{14}|\d{18})$/
export const regColor = /^(#){1}([0-9 a-f A-F]){6}$/

export const regEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
export const regPassword = /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]{6,}$/
// 主动触发窗口变化事件，让图表根据窗口变化而自适应
export const resetView = () => {
  if (document.createEvent) {
      const event = document.createEvent('HTMLEvents')
      event.initEvent('resize', true, true)
      window.dispatchEvent(event)
  } else if (document.createEventObject) {
      window.fireEvent('onresize')
  }
}
